﻿using Ledict.ConditionExtract.BLL;
using Ledict.ConditionExtract.BLL.WorkProcess;
using Ledict.ConditionExtract.Common;
using Ledict.ConditionExtract.Model;
using Ledict.Utility.Helper;
using Ledict.Utility.Msg;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Ledict.ConditionExtract
{
    /// <summary>
    /// 数据处理
    /// </summary>
    public partial class DataProcess : Form
    {
        #region 界面初始化

        //静态锁
        private static readonly object Lock = new object();

        static DataProcess _default;
        public static DataProcess Default
        {
            get
            {
                if (_default == null || _default.IsDisposed)
                {
                    lock (Lock)
                    {
                        if (_default == null || _default.IsDisposed)
                        {
                            _default = new DataProcess();
                        }
                    }

                }
                return _default;
            }
        }
        public DataProcess()
        {
            InitializeComponent();
            t_Case_HeadWords.TreeView.AfterExpand += new TreeViewEventHandler(t_Case_HeadWords_AfterExpand);
            t_Global_Court.TreeView.AfterExpand += new TreeViewEventHandler(t_Global_Court_AfterExpand);
            NowProcessNode.TreeView.AfterExpand += new TreeViewEventHandler(NowProcessNode_AfterExpand);
        }

        #endregion

        TreeDataBLL trbll = new TreeDataBLL();
        CaseCauseBLL casecausebLL = new CaseCauseBLL();
        Express_WordBLL wordbll = new Express_WordBLL();
        Express_AddElement addelementbll = new Express_AddElement();
        NewIDBLL newid = new NewIDBLL();
        //AboutRegexBLL regexbll = new AboutRegexBLL();
        //Ledict.Regex.BLL.Reg_RegexsBLL addreg = new Ledict.Regex.BLL.Reg_RegexsBLL();
        ExpressGroupSituationBLL expresitu = new ExpressGroupSituationBLL();
        //Express_MatchSituationBLL match = new Express_MatchSituationBLL();
        //Express_SourceBLL SourceBLL = new Express_SourceBLL();

        //AboutRegexBLL aboutreg = new AboutRegexBLL();
        RegexParse.RegexParse getregex = new RegexParse.RegexParse();

        //ProcessDataSourceBLL datas = new ProcessDataSourceBLL();
        WorkThread_Public work = new WorkThread_Public();
        //ElementAnalyze ea = new ElementAnalyze();
        WordBankKeyWordsBLL wordbankkeywordsbll = new WordBankKeyWordsBLL();
        //Reg_InfoRegexRelationBLL unitrelation = new Reg_InfoRegexRelationBLL();
        Express_WordBankRelBLL express_wordbankrelbll = new Express_WordBankRelBLL();
        WordBankBLL wordbankbll = new WordBankBLL();
        DataProcess_EditNode dataprocess_editnode = new DataProcess_EditNode();
        Express_MatchSituationBLL express_matchsituationbll = new Express_MatchSituationBLL();

        #region 共有变量

        private string sort = "";
        private string IsASC = "";
        private string SelectText = "";
        private string SelectWBK_ID = "";
        private TreeNode clicknode = null;
        private string IsAddData = "";

        private string TypeName = "刑事案由";
        string EW_IDText = "";
        int GridViewRowNumber = 0;

        int IsContentOrAddElement = 1;//1为编辑文本0 为编辑要素
        private string FirId = "1000";
        private List<TreeNode> NodeList = new List<TreeNode>();


        #endregion

        private void DataProcess_Load(object sender, EventArgs e)//初始化树
        {
            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            DV_AddElement.AutoGenerateColumns = false;
            DV_AddElement.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            GetData("t_Case_HeadWords");
            GetData("t_Case_JudicialProcedure");
            GetData("t_Case_Property");
            GetData("t_Case_ParagraphType");

            GetData("t_Global_Court");

            CaseCauseTree();
            CaseCauseTree_Process();

        }

        #region 左侧树

        public void CaseCauseTree()
        {
            #region 初始化
            this.tVCaseCause.Nodes.Clear();
            NodeList = new List<TreeNode>();

            StacticQuery.Text = "";
            CurrNodeNum.Text = "";
            SumQuery.Text = "";
            #endregion

            DataTable dt = trbll.GetCauseTree_Two("", 0);// 第一层

            if (dt.Rows.Count > 0)
            {
                DataRow[] arrayDR = dt.Select("name='" + TypeName + "'");

                foreach (DataRow CaseTreeNodeRode in arrayDR)
                {
                    TreeNode node = new TreeNode();

                    node.Text = LdFormat.ObjectToString(CaseTreeNodeRode["name"]);
                    node.Tag = CaseTreeNodeRode["id"];
                    node.Name = LdFormat.ObjectToString(CaseTreeNodeRode["CC_NodeType"].ToString() + "," + CaseTreeNodeRode["TableName"].ToString());
                    FirId = CaseTreeNodeRode[0].ToString();
                    if (trbll.GetCauseTree_Two(node.Tag.ToString(), 0).Rows.Count > 0)//第二层
                    {
                        node.Nodes.Add(new TreeNode());
                    }
                    tVCaseCause.Nodes.Add(node);
                    NodeList.Add(node);
                }
            }
        }
        /// <summary>
        /// 显示下一级树节点
        /// </summary>
        /// <param name="parentNode"></param>
        private void CaseCauseTreeChild(TreeNode parentNode)
        {
            DataTable CaseTreeNodeRode = GetChild(parentNode);
            if (CaseTreeNodeRode.Rows.Count == 0)
                return;
            for (int i = 0; i < CaseTreeNodeRode.Rows.Count; i++)//下级
            {

                TreeNode node = new TreeNode();

                node.Text = LdFormat.ObjectToString(CaseTreeNodeRode.Rows[i]["name"]);
                node.Tag = CaseTreeNodeRode.Rows[i]["id"];
                node.Name = LdFormat.ObjectToString(CaseTreeNodeRode.Rows[i]["CC_NodeType"].ToString() + "," + CaseTreeNodeRode.Rows[i]["TableName"].ToString());

                if (node.Text == "组合" || GetChild(node).Rows.Count > 0)
                {
                    node.Nodes.Add(new TreeNode());
                }

                parentNode.Nodes.Add(node);
                NodeList.Add(node);
            }
        }
        //获取下一级树节点
        private DataTable GetChild(TreeNode parentNode)
        {
            string pid = parentNode.Tag.ToString();
            string pName = parentNode.Text.ToString();

            string[] name = parentNode.Name.ToString().Split(',');
            int ptype = Convert.ToInt32(name[0]);
            int TableName = Convert.ToInt32(name[1]);
            int childType = trbll.GetChildType(pid, ptype, TableName);//下级改去哪个表查0：CaseCause 1:SYS_Express_GroupSituation
            DataTable CaseTreeNodeRode = new DataTable();
            if (childType == 1)
            {

                if (TableName == 0) //如果是第一级 找组合单一
                {
                    int CC_IsCombination = 0;
                    SYS_CaseCause model = casecausebLL.GetCaseCauseByCCID(pid);
                    if (model != null && model.CC_IsCombination == 1)
                        CC_IsCombination = 1;
                    CaseTreeNodeRode = trbll.GetCauseTreeTwo_ToExpressTab_Virtual(pid, CC_IsCombination);

                }
                else
                {
                    if (pName == "组合") //如果是组合的，去前缀
                        pid = pid.Substring(1, pid.Length - 1);
                    CaseTreeNodeRode = trbll.GetCauseTreeTwo_ToExpressTab(pid, 0);//SYS_Express_GroupSituation 
                }
            }
            else
            {
                if (pName == "单一") //如果是组合的，去前缀
                    pid = pid.Substring(1, pid.Length - 1);
                CaseTreeNodeRode = trbll.GetCauseTree_Two(pid, 0); //CaseCause
            }
            return CaseTreeNodeRode;

        }


        private void tVCaseCause_AfterExpand(object sender, TreeViewEventArgs e)
        {
            if (e.Node.FirstNode.Tag == null)
            {
                e.Node.Nodes.Clear();

                CaseCauseTreeChild(e.Node);
            }
        }
        private void tVCaseCause_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (clicknode != null)
                clicknode.ForeColor = Color.Black;
            clicknode = e.Node;//保存节点
            clicknode.ForeColor = Color.Red;
            IsAddData = "";
            SelectText = "";
            SelectWBK_ID = "";
            if (clicknode.Text.Contains("（"))
            {
                panel_Attribute.Enabled = false;
            }
            else
            {
                panel_Attribute.Enabled = true;
            }
            dataPagerMain.ChangePageNumber(1);
            ShowRegText();

        }



        /// <summary>
        /// 是否有用情形
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool IsUseFul(TreeViewEventArgs e)
        {
            //int type = Convert.ToInt32(e.Node.Name.ToString().Split (',')[0]);
            //if (type == 4 || type == 5 || type == 6 || type == 7 || type == 8)
            //{
            return true;
            //}
            //return false;
        }
        #endregion

        #region 右侧信息列表
        /// <summary>
        /// 列表显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void dataPagerMain_PageNumberChanging(object sender, Controls.DataPagerPageIndexChangingEventArgs e)
        {
            if (clicknode != null)
            {
                var startRowIndex = e.StartRowIndex;
                var maximumRows = e.MaximumRows;
                var endRowIndex = e.StartRowIndex + e.MaximumRows;
                DataTable dt = new DataTable();
                string id = clicknode.Tag.ToString();
                //第一种表述节点
                //第二种原SYS_CaseCause节点
                int ismatch = IsMatch.Checked ? 1 : 0;
                string AffirmIdeaResult = IsAffirmIdeaResult.Checked ? "1" : "2";
                id = expresitu.GetES_IDsByCCId(id, ismatch, AffirmIdeaResult);
                dt = wordbll.GetExractContent(id, sort, IsASC, SelectText, SelectWBK_ID, 0);


                if (dt.Rows.Count > 0)
                {
                    e.TotalCount = dt.Rows.Count;
                    DataTable newdt = new DataTable();
                    newdt = dt.Clone();
                    DataRow[] dr = dt.Select("showindex>" + startRowIndex + " and showindex<=" + endRowIndex);
                    for (int i = 0; i < dr.Length; i++)
                    {
                        newdt.ImportRow((DataRow)dr[i]);
                    }
                    dataGridView1.DataSource = newdt;
                }
                else
                {
                    dataGridView1.DataSource = new DataTable();
                }
            }

        }
        /// <summary>
        /// 转到添加要素界面
        /// </summary>
        private void ToAddWordBanks()
        {
            tabControl1.SelectTab("tabPage2");
            if (null != clicknode)
            {
                linkAddWB.Text = string.Format("<<{0}", clicknode.Text);
            }
            GetWordkeyByCCId();
        }

        /// <summary>
        /// 转到添加要素界面
        /// </summary>
        private void ShowRegText()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ER_Name");
            dt.Columns.Add("ER_OperateType");
            dt.Columns.Add("ER_RegexText");
            string id = clicknode.Tag.ToString();
            id = expresitu.GetES_SituationIdsById(id);
            string regCode = casecausebLL.GetRegCodeByJudgeBook(id);
            IList<Ledict.Regex.Model.Reg_Regex> reglist = getregex.GetRegexs(regCode);
            foreach (Ledict.Regex.Model.Reg_Regex item in reglist)
            {
                DataRow dr = dt.NewRow();
                dr[0] = item.ER_Name;
                switch (item.ER_OperateType)
                {
                    case 1: dr[1] = "提取";
                        break;
                    case 2: dr[1] = "替换";
                        break;
                    case 3: dr[1] = "匹配";
                        break;

                }
                dr[2] = item.ER_RegexText;
                dt.Rows.Add(dr);
            }

            GV_Reg.DataSource = dt;
        }


        /// <summary>
        /// 转到节点树界面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            tabControl1.SelectTab("tabPage1");

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DV_AddElement_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)  //添加节点重跑数据
            {
                try
                {
                    OpenNodeTree();
                }
                catch (Exception error)
                {
                    MessageBox.Show("添加要素失败!");
                }
            }
            else if (e.ColumnIndex == 0)
            {
                // SelectText  = WhereLike.ToWherelike(DV_AddElement.Rows[e.RowIndex].Cells["Element"].Value.ToString().Replace("\r\n", ""), "EW_Content", 1);  
                SelectWBK_ID = DV_AddElement.Rows[e.RowIndex].Cells["WBK_ID"].Value.ToString();
                SelectText = "";

                dataPagerMain.ChangePageNumber(1);

            }

        }
        private void GetWordkeyByCCId()
        {
            Dictionary<string, int> ResultText = new Dictionary<string, int>();

            string id = clicknode.Tag.ToString();

            //第一种表述节点
            //第二种原SYS_CaseCause节点
            int ismatch = IsMatch.Checked ? 1 : 0;
            string AffirmIdeaResult = IsAffirmIdeaResult.Checked ? "1" : "2";
            id = expresitu.GetES_IDsByCCId(id, ismatch, AffirmIdeaResult);
            DataTable wordBankKeysdt = wordbll.GetAllwordBankKeys(id);
            DV_AddElement.DataSource = wordBankKeysdt;

        }


        /// <summary>
        /// 编辑列表（单击）
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                #region 对勾和差
                if (e.ColumnIndex == 7 || e.ColumnIndex == 8)
                {
                    DataGridViewCheckBoxCell checkCellRight = (DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells["Right"];
                    DataGridViewCheckBoxCell checkCellwrong = (DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells["wrong"];
                    if (e.ColumnIndex == 7)
                    {
                        if (Convert.ToBoolean(checkCellRight.Value) == true)
                        {
                            checkCellRight.Value = false;
                            checkCellwrong.Value = true;
                        }
                        else
                        {
                            checkCellRight.Value = true;
                            checkCellwrong.Value = false;
                        }

                    }
                    if (e.ColumnIndex == 8)
                    {
                        if (Convert.ToBoolean(checkCellwrong.Value) == true)
                        {
                            checkCellRight.Value = true;
                            checkCellwrong.Value = false;
                        }
                        else
                        {
                            checkCellRight.Value = false;
                            checkCellwrong.Value = true;
                        }
                    }

                    SYS_Express_Word model = new SYS_Express_Word();
                    model.EW_Right = Convert.ToInt32(checkCellRight.Value);
                    model.EW_Wrong = Convert.ToInt32(checkCellwrong.Value);
                    model.EW_ID = dataGridView1.Rows[e.RowIndex].Cells["EW_ID"].Value.ToString();

                    wordbll.UpdateChooseState_Process(model);
                    if (model.EW_Right == 1)//添加到表述库加工
                    {
                        model = wordbll.GetModel_Process(dataGridView1.Rows[e.RowIndex].Cells["EW_ID"].Value.ToString());

                        UpdateCC_IsShowExpress(clicknode);

                        if (!wordbll.Exists_Word(model))
                        {
                            wordbll.Add_Word(model);//添加word 表
                        }
                    }
                }

                #endregion
                if (e.ColumnIndex == 2)  //编辑文本
                {

                    EW_IDText = dataGridView1.Rows[e.RowIndex].Cells["EW_ID"].Value.ToString();

                    textBox1.Text = "";
                    textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells["EW_Content"].Value.ToString();
                    //byte[] buffer = Encoding.UTF8.GetBytes(dataGridView1.Rows[e.RowIndex].Cells["EW_Content"].Value.ToString());
                    //textBox1.Text = Encoding.GetEncoding("UTF-8").GetString(buffer);
                    GridViewRowNumber = e.RowIndex;
                    ColorWord();

                }

            }

        }

        /// <summary>
        /// 自己和所有父级节点记状态
        /// </summary>
        /// <param name="NowNode"></param>
        private void UpdateCC_IsShowExpress(TreeNode NowNode)
        {

            wordbll.UpdateCC_IsShowExpress(NowNode.Tag.ToString(), 1);
            if (NowNode.Parent != null)
                UpdateCC_IsShowExpress(NowNode.Parent);
        }


        private void Delete_Click(object sender, EventArgs e)
        {
            string DeleteID = "";
            if (MessageBox.Show("确认要删除数据吗？", "此删除不可恢复", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
                    {
                        DataGridViewCheckBoxCell check = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells["Column1"];
                        if (Convert.ToBoolean(check.Value) == true)
                        {
                            DeleteID = dataGridView1.Rows[i].Cells["EW_ID"].Value.ToString();
                            if (DeleteID != "")
                            {

                                wordbll.Delete_WordProcess(DeleteID);
                            }

                        }
                    }
                    MessageBox.Show("删除成功!");
                }
                catch (Exception error)
                {
                    MessageBox.Show("删除失败!");
                }
                dataPagerMain.ChangePageNumber(1);
            }
        }



        /// <summary>
        /// 显示窗体，自动将窗体填满父窗体的工作区
        /// </summary>
        /// <param name="childForm"></param>
        private void ShowForm(Form childForm)
        {
            childForm.MdiParent = this.MdiParent;
            childForm.StartPosition = FormStartPosition.CenterParent;
            childForm.Show();
            childForm.Activate();
            childForm.Dock = DockStyle.Fill;
            var size = childForm.Size;
            var location = childForm.Location;
            childForm.Dock = DockStyle.None;
            childForm.Size = size;
            childForm.Location = location;
        }
        /// <summary>
        /// 修改文本 
        /// </summary>=""
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateWord_Click(object sender, EventArgs e)
        {
            if (IsContentOrAddElement == 1)
            {
                if (wordbll.UpdateContent(EW_IDText, textBox1.Text))
                {
                    MessageBox.Show("修改成功!");
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }


                DataGridViewCell checkCellwrong = (DataGridViewCell)dataGridView1.Rows[GridViewRowNumber].Cells["EW_Content"];
                checkCellwrong.Value = textBox1.Text;

            }

        }
        #endregion

        #region 多线程

        WorkThread workObj = new WorkThread();
        //工作对象
        private Thread workThread;





        //暂停(只针对第一次加工数据)
        private void Endbtn_Click(object sender, EventArgs e)
        {
            if (workThread != null)
            {
                workThread.Abort();
                workThread = null;
            }
        }

        // 显示进度条
        public void ShowProgress(int maxCount, int currentCount)
        {
            if (this.progressBar1.InvokeRequired == false)
            {
                if (currentCount < maxCount)
                {
                    progressBar1.Value = currentCount;
                    progressBar1.Maximum = maxCount;
                    progressBar1.Text = currentCount + "/" + maxCount;
                    label1.Text = "当前" + currentCount + "条";
                }
                else if (currentCount == maxCount)
                {
                    progressBar1.Value = currentCount;
                    progressBar1.Maximum = maxCount;
                    progressBar1.Text = currentCount + "/" + maxCount;
                    label1.Text = "已完成!";
                    workThread = null;
                    StaticCacheBLL.plotchildDict = new Dictionary<string, DataTable>();//清除规则缓存
                }
            }
            else
            {
                ProcessShow processshow = new ProcessShow(ShowProgress);
                this.Invoke(processshow, new object[] { maxCount, currentCount });
            }

        }


        /// <summary>
        /// 开始执行线程
        /// </summary>
        private void ThreadExecute(DataSourceCondition condi, string luceneSearchType)
        {
            //  workThread = null;
            workObj.processShow = ShowProgress;
            workObj.closeForm = CloseForm;
            workObj.conditon = condi;

            workObj.LuceneSearchType = luceneSearchType.ToUpper();//设置查询lucene方法

            //workThread = new Thread(workObj.execute_Start);
            workThread = new Thread(workObj.execute_Start);
            workThread.Start();
        }


        #endregion

        #region  加工条件
        /// <summary>
        /// 开始加工(组织条件)第一次加工
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        private void StartBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (t_Case_HeadWords.Text.Trim() != "" && t_Case_JudicialProcedure.Text.Trim() != "" && t_Case_Property.Text.Trim() != "" && t_Case_ParagraphType.Text.Trim() != "" && NowProcessNode.Text.Trim() != "")
                {
                    if (workThread == null)//创建线程
                    {
                        #region 查询条件
                        //条件
                        var condi = new DataSourceCondition
                        {
                            CaseIdStart = CaseIdStart.Text.Trim(),
                            CaseIdEnd = CaseIdEnd.Text.Trim(),
                            HeadwordId = t_Case_HeadWords.Text,
                            JudicialProcedureId = t_Case_JudicialProcedure.Text.Trim(),
                            PropertyId = t_Case_Property.Text.Trim(),
                            ParagraphType = t_Case_ParagraphType.Text.Trim(),
                            Court = t_Global_Court.Text.Trim(),
                            SituationId = NowProcessNode.Text.Trim()
                        };

                        #endregion

                        //todo by zhangpeng:Lucene查询方法（WCF或直接通过共享方法调用）两个值：WCF，Share
                        var dataProcessType = ConfigHelper.AppSettings("LuceneSearchType");

                        if (!string.IsNullOrEmpty(dataProcessType)) dataProcessType = "wcf";

                        workObj = WorkThreadFactory.CreateWorkThreadObj(work.IsCriminal(condi.SituationId) ?
                               "WorkThread_first_Crime" : "WorkThread_first_People");

                        //开始执行
                        ThreadExecute(condi, dataProcessType);





                    }
                    else//暂停后重启
                    {
                        MsgBox.Warn("当前操作未完成，请等待");
                        // workObj.Resume();
                    }

                }
                else
                {
                    MsgBox.Warn(@"案由、案件类别、裁决程序不可为空，请重新填写!");
                }
            }
            catch (Exception error)
            {
                MsgBox.Err("系统报错，请查看错误日志!");
                AddLog.WriteLog(error, "");
            }
        }

        #region  重加工
        /// <summary>
        /// 重跑数据开始(立即处理)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Start_Again(Dictionary<string, string> AddEleDic)
        {

            //workObj = WorkThreadFactory.CreateWorkThreadObj("second");

            //NodeTree ae = NodeTree.Default;
            //if (ae.LocateNode != "")
            //{
            //    ae.Close();
            //}

            //StringBuilder elements = new StringBuilder();

            //foreach (KeyValuePair<string, string> kv in AddEleDic)//一个一个开始
            //{
            //    #region 查询条件

            //    DataSourceCondition condi = new DataSourceCondition(); //条件
            //    condi.ISAgainData = true;
            //    condi.SituationId = kv.Key;
            //    conditonList.Add(condi);
            //    #endregion

            //}
            //Threadexecute();
        }

        /// <summary>
        /// 开始处理"暂不处理"的要素（稍后处理）
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExecAllStart_Click(object sender, EventArgs e)
        {
            //workObj = WorkThreadFactory.CreateWorkThreadObj("second");
            //conditonList.Clear();

            //DataTable AllElem = addelementbll.GetAllElement();

            //for (int i = 0; i < AllElem.Rows.Count; i++)
            //{

            //    #region 查询条件

            //    DataSourceCondition condi = new DataSourceCondition(); //条件
            //    condi.ISAgainData = true;
            //    condi.SituationId = AllElem.Rows[i]["StiuatonId"].ToString();
            //    conditonList.Add(condi);
            //    #endregion

            //}
            //// workObj

            //Threadexecute();

            ////清库
            //wordbll.UpdateClearElement_Process();
        }


        /// <summary>
        /// 保存"暂不处理"的要素（稍后处理）
        /// </summary>
        /// <param name="AddEleDic"></param>
        public void SaveElement(Dictionary<string, string> AddEleDic)
        {
            NodeTree ae = NodeTree.Instance;
            if (ae.LocateNode != "")
            {
                ae.Close();
            }

            StringBuilder elements = new StringBuilder();
            foreach (KeyValuePair<string, string> kv in AddEleDic)
            {
                addelementbll.AddExpress_AddElement(kv.Key, kv.Value);
                elements.Append("," + kv.Value);
            }

            wordbll.UpdateAddElement_Process(EW_IDText, elements.ToString());
            dataPagerMain.ChangePageNumber(dataPagerMain._currentPageNumber);
        }


        #endregion

        #endregion

        #region 小功能（刷新关闭 有问题）


        bool closeState = false;
        //关闭
        private void DataProcess_FormClosing(object sender, FormClosingEventArgs e)
        {

            if (workThread != null && workThread.IsAlive && e.CloseReason == CloseReason.UserClosing && !closeState)
            {
                workObj.Stop();

                e.Cancel = true;
            }

        }
        public void CloseForm()
        {
            if (this.progressBar1.InvokeRequired == false)
            {
                closeState = true;
                Close();
            }
            else
            {
                CloseForm closeForm = new CloseForm(CloseForm);
                this.Invoke(closeForm);
            }
        }
        //刷新
        private void button3_Click(object sender, EventArgs e)
        {
            CaseCauseTree();
        }
        #endregion


        #region 界面显示（非核心功能）

        #region 查询节点(有问题)
        DataTable Querydt;
        private void QueryNodeTxt_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                QueryNode();
            }

        }

        private void QueryNode()
        {
            string QueryNodeName = QueryNodeTxt.Text.Trim();

            if (QueryNodeName != "")
            {
                Querydt = trbll.NodeTree_Query(FirId, QueryNodeName, 2);
                StacticQuery.Text = Querydt.Rows.Count.ToString();
                if (Querydt.Rows.Count > 0)
                {
                    CurrNodeNum.Text = "1";
                    SumQuery.Text = CurrNodeNum.Text;
                    int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
                    LinkIsVisible(CurrNode);
                    QueryNode_Page(Querydt, CurrNode);
                }
                else
                {
                    CurrNodeNum.Text = "0";
                    SumQuery.Text = CurrNodeNum.Text;
                    MessageBox.Show("没有查询到结果！");
                }
            }
            else
            {
                MessageBox.Show("请输入关键字！");
            }
        }




        private void QueryNodeBtn_Click(object sender, EventArgs e)//查询
        {
            QueryNode();
        }
        /// <summary>
        /// 下一条
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Nextlinkbtn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CurrNodeNum.Text = (Convert.ToInt32(CurrNodeNum.Text) + 1).ToString();
            SumQuery.Text = CurrNodeNum.Text;
            int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
            QueryNode_Page(Querydt, CurrNode);
            LinkIsVisible(CurrNode);


        }
        /// <summary>
        /// 上一条
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Prelinkbtn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CurrNodeNum.Text = (Convert.ToInt32(CurrNodeNum.Text) - 1).ToString();
            SumQuery.Text = CurrNodeNum.Text;
            int CurrNode = Convert.ToInt32(CurrNodeNum.Text);
            QueryNode_Page(Querydt, CurrNode);
            LinkIsVisible(CurrNode);

        }
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="showindex"></param>
        private void QueryNode_Page(DataTable dt, int showindex)
        {
            if (dt.Rows.Count >= showindex)
            {
                string[] NotePidArr = trbll.GetAllParentNode(dt.Rows[showindex - 1]["id"].ToString()).Split(',');
                for (int i = 0; i < NotePidArr.Length; i++)
                {

                    if (i != NotePidArr.Length - 1)
                    {
                        FindNode(NotePidArr[i]).Expand();
                    }
                    else
                    {
                        TreeNode node = FindNode(NotePidArr[i]);
                        this.tVCaseCause.SelectedNode = node;

                    }
                }
            }
            else
            {
                MessageBox.Show("跳转页码有误，重新输入！");
            }


        }
        /// <summary>
        /// 找到节点
        /// </summary>
        /// <param name="Nodeid"></param>
        /// <returns></returns>
        private TreeNode FindNode(string Nodeid)
        {
            foreach (TreeNode node in NodeList)
            {
                if (node.Tag.ToString() == Nodeid)
                {
                    return node;
                }
            }
            return null;

        }
        /// <summary>
        /// 上一条下一条是否可用
        /// </summary>
        /// <param name="CurrNode"></param>
        private void LinkIsVisible(int CurrNode)
        {
            Prelinkbtn.Enabled = true;
            Nextlinkbtn.Enabled = true;
            if (CurrNode <= 1)
            {
                Prelinkbtn.Enabled = false;
            }
            if (CurrNode >= Querydt.Rows.Count)
            {
                Nextlinkbtn.Enabled = false;
            }




        }
        /// <summary>
        /// 跳页查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GoQuery_Click(object sender, EventArgs e)
        {
            int CurrNode = Convert.ToInt32(SumQuery.Text);

            if (Querydt.Rows.Count >= CurrNode)
            {
                CurrNodeNum.Text = SumQuery.Text;
                QueryNode_Page(Querydt, CurrNode);
                LinkIsVisible(CurrNode);
            }
            else
            {
                MessageBox.Show("跳转页码有误，重新输入！");
            }

        }

        #endregion

        #region 各种树菜单(案由、类型)
        public void GetData(string Tname)
        {
            DataTable dt = trbll.GetTreeHeadWords("", Tname);// 第一层
            DataRow[] arrayDR = dt.Select();

            foreach (DataRow CaseTreeNodeRode in arrayDR)
            {
                TreeNode node = new TreeNode();

                node.Text = CaseTreeNodeRode["name"].ToString() + "(" + CaseTreeNodeRode["id"].ToString() + ")";
                node.Tag = CaseTreeNodeRode["id"];

                switch (Tname)
                {
                    case "t_Case_HeadWords":
                        if (trbll.GetTreeHeadWords(node.Tag.ToString(), Tname).Rows.Count > 0)//第二层
                        {
                            node.Nodes.Add(new TreeNode());
                        }
                        t_Case_HeadWords.TreeView.Nodes.Add(node);
                        break;
                    case "t_Case_JudicialProcedure":
                        t_Case_JudicialProcedure.TreeView.Nodes.Add(node);
                        break;
                    case "t_Case_ParagraphType":
                        t_Case_ParagraphType.TreeView.Nodes.Add(node);
                        break;

                    case "t_Global_Court":
                        if (trbll.GetTreeHeadWords(node.Tag.ToString(), Tname).Rows.Count > 0)//第二层
                        {
                            node.Nodes.Add(new TreeNode());
                        }
                        t_Global_Court.TreeView.Nodes.Add(node);
                        break;

                    case "t_Case_Property":
                        t_Case_Property.TreeView.Nodes.Add(node);
                        break;

                }



            }
        }
        public void GetTreeHeadWordsChild(TreeNode parentNode, string Tname)
        {
            DataTable dt = trbll.GetTreeHeadWords(parentNode.Tag.ToString(), Tname);// 第一层
            DataRow[] arrayDR = dt.Select();

            foreach (DataRow CaseTreeNodeRode in arrayDR)
            {
                TreeNode node = new TreeNode();

                node.Text = LdFormat.ObjectToString(CaseTreeNodeRode["name"]) + "(" + CaseTreeNodeRode["id"] + ")";
                node.Tag = CaseTreeNodeRode["id"];
                //判断是否有子节点
                if (trbll.GetTreeHeadWords(node.Tag.ToString(), Tname).Rows.Count > 0)//第二层
                {
                    node.Nodes.Add(new TreeNode());
                }
                parentNode.Nodes.Add(node);

            }

        }

        public void t_Case_HeadWords_AfterExpand(object sender, TreeViewEventArgs e)
        {
            e.Node.Nodes.Clear();
            GetTreeHeadWordsChild(e.Node, "t_Case_HeadWords");
        }
        public void t_Global_Court_AfterExpand(object sender, TreeViewEventArgs e)
        {
            e.Node.Nodes.Clear();
            GetTreeHeadWordsChild(e.Node, "t_Global_Court");
        }
        #endregion

        #region 刑事民事行政按钮(显示不同树)
        public void GetColor()
        {
            button8.BackColor = Color.White;
            button6.BackColor = Color.White;
            button5.BackColor = Color.White;
            button4.BackColor = Color.White;
            button7.BackColor = Color.White;
        }
        private void button8_Click(object sender, EventArgs e)
        {
            TypeName = "刑事案由";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            TypeName = "民事案由";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            TypeName = "行政案由";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            TypeName = "赔偿案由";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            TypeName = "执行案由";
            GetColor();
            Button sendButton = (Button)sender;
            sendButton.BackColor = Color.LightSkyBlue;
            CaseCauseTree();
        }

        #endregion

        #region 各种排序(字长、数目)

        private void SelectAdd_Click(object sender, EventArgs e)
        {
            if (txt_SelectWord.Text.Trim() != "")
                SelectText = WhereLike.ToWherelike(txt_SelectWord.Text.Trim(), "EW_Content", 1);
            else
                SelectText = "";

            dataPagerMain.ChangePageNumber(1);
        }

        private void SelectCut_Click(object sender, EventArgs e)
        {
            if (txt_SelectWord.Text.Trim() != "")
                SelectText = WhereLike.ToWherelike(txt_SelectWord.Text.Trim(), "EW_Content", 0);
            else
                SelectText = "";
            dataPagerMain.ChangePageNumber(1);
        }


        private void WordLengSort_Click(object sender, EventArgs e)
        {
            sort = "WordLengSort";
            if (IsASC == "")
            {
                IsASC = "desc";
            }
            else
            {
                IsASC = "";
            }
            dataPagerMain.ChangePageNumber(1);
        }

        private void AlphabetSort_Click(object sender, EventArgs e)
        {
            sort = "AlphabetSort";
            if (IsASC == "")
            {
                IsASC = "desc";
            }
            else
            {
                IsASC = "";
            }
            dataPagerMain.ChangePageNumber(1);
        }

        private void CountSort_Click(object sender, EventArgs e)
        {
            sort = "CountSort";
            if (IsASC == "")
            {
                IsASC = "desc";
            }
            else
            {
                IsASC = "";
            }
            dataPagerMain.ChangePageNumber(1);
        }

        private void ISCheckSort_Click(object sender, EventArgs e)
        {
            sort = "RightSort";
            if (IsASC == "")
            {
                IsASC = "desc";
            }
            else
            {
                IsASC = "";
            }
            dataPagerMain.ChangePageNumber(1);


        }

        private void NotCheckSort_Click(object sender, EventArgs e)
        {

        }
        private void IsMatch_Click(object sender, EventArgs e)
        {
            dataPagerMain.ChangePageNumber(1);
            SelectText = "";
            SelectWBK_ID = "";
            if (tabControl1.SelectedIndex == 1)
            {
                ToAddWordBanks();
            }
        }

        private void NotMatch_Click(object sender, EventArgs e)
        {
            dataPagerMain.ChangePageNumber(1);
            SelectText = "";
            SelectWBK_ID = "";
            if (tabControl1.SelectedIndex == 1)
            {
                ToAddWordBanks();
            }
        }

        private void IsAffirmIdeaResult_Click(object sender, EventArgs e)
        {
            dataPagerMain.ChangePageNumber(1);
            SelectText = "";
            SelectWBK_ID = "";
            if (tabControl1.SelectedIndex == 1)
            {
                ToAddWordBanks();
            }
        }

        private void NotAffirmIdeaResult_Click(object sender, EventArgs e)
        {
            dataPagerMain.ChangePageNumber(1);
            if (tabControl1.SelectedIndex == 1)
            {
                ToAddWordBanks();
            }
        }



        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            AddWordBank();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            AddWordBank();
            EW_IDText = dataGridView1.Rows[GridViewRowNumber].Cells["EW_ID"].Value.ToString();
            textBox1.Text = "";
            textBox1.Text = dataGridView1.Rows[GridViewRowNumber].Cells["EW_Content"].Value.ToString();
            ColorWord();
        }

        private void AddWordBank()
        {
            try
            {
                SYS_WordBank_KeyWords model = new SYS_WordBank_KeyWords();
                string addelement = textBox1.SelectedText;
                string[] WordsTextArr = addelement.Split(',', '，', ';', '；');
                foreach (var item in WordsTextArr)
                {
                    if (item != "")
                    {
                        DataTable dt = wordbankbll.GetWB_IDByHeadword(clicknode.Tag.ToString());
                        if (dt.Rows.Count > 0)
                            model.WB_ID = dt.Rows[0]["WB_ID"].ToString();
                        else
                            model.WB_ID = clicknode.Tag.ToString();
                        model.WBK_Word = item;
                        model.WBK_Length = item.Length;
                        wordbankkeywordsbll.Add(model);
                    }
                }

                MessageBox.Show("添加词库成功！");
            }
            catch (Exception error)
            {
                MessageBox.Show("添加词库失败！");
            }

        }

        private void ColorWord()
        {
            #region 标红词库
            textBox1.SelectionBackColor = Color.White;

            string EW_ID = dataGridView1.Rows[GridViewRowNumber].Cells["EW_ID"].Value.ToString();
            string MS_ID = dataGridView1.Rows[GridViewRowNumber].Cells["MS_ID"].Value.ToString();
            IsContentOrAddElement = 1;

            DataTable dt = express_wordbankrelbll.Get_Express_WordBankRel(EW_ID);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StateWord(dt.Rows[i]["WBK_Word"].ToString());

            }

            #endregion
        }

        private void StateWord(string SelectWord)
        {

            textBox1.SelectionStart = 0;
            textBox1.SelectionLength = textBox1.Text.Length;

            System.Text.RegularExpressions.MatchCollection mc;
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(SelectWord); //定义一个Regex对象实例
            mc = r.Matches(textBox1.Text);
            for (int i = 0; i < mc.Count; i++) //在输入字符串中找到所有匹配
            {
                int start = mc[i].Index; //记录匹配字符的位置
                int length = (SelectWord).Length;
                textBox1.SelectionStart = start;
                textBox1.SelectionLength = length;
                textBox1.SelectionBackColor = Color.Red;
            }
        }
        #endregion


        private void AddExpressWprd_Click(object sender, EventArgs e)
        {
            try
            {

                string CC_IDList = clicknode.Tag.ToString();
                string caseid = "1000000";
                string ParagraphID = "150";
                string resultText = textBox1.Text;
                if (casecausebLL.GetSYS_CaseCauseByCCID(CC_IDList).Rows.Count > 0)//单一节点
                {
                    DataTable processNodedt = work.BelongCaseCauseID(CC_IDList);//节点匹配数据开始处
                    if (processNodedt.Rows.Count > 0)
                    {
                        work.AddToExpress(resultText, caseid, ParagraphID, processNodedt.Rows[0]["CC_ID"].ToString(), CC_IDList);

                    }
                }
                else//组合节点
                {
                    #region 添加文本
                    SYS_Express_Word WordModel = new SYS_Express_Word();
                    WordModel.MS_ID = CC_IDList;
                    WordModel.EW_CaseId = caseid;
                    WordModel.EW_Content = resultText;
                    WordModel.EW_UseCount = 1;
                    WordModel.EW_WordCount = resultText.Length;
                    WordModel.ParagraphTypeId = Convert.ToInt32(ParagraphID);
                    WordModel.EW_ID = wordbll.Exists_WordProcess(WordModel);
                    if (WordModel.EW_ID == "")
                    {
                        WordModel.EW_ID = newid.JudgeDoc_CreateID("SYS_Express_Word");
                        WordModel.EW_Right = 0;
                        WordModel.EW_Wrong = 0;
                        wordbll.AddWord_Process(WordModel);
                    }
                    else
                    {
                        wordbll.UpdateWord_Process(WordModel);
                    }
                    #endregion
                    #region 词库
                    List<string> EW_AddElementStr = express_wordbankrelbll.WordBank("", WordModel.EW_Content);
                    foreach (var item in EW_AddElementStr)
                    {
                        if (!express_wordbankrelbll.Exists(WordModel.EW_ID, item))
                        {
                            express_wordbankrelbll.Add_Express_WordBankRel(newid.JudgeDoc_CreateID("SYS_Express_WordBankRel"), WordModel.EW_ID, item);
                        }
                    }
                    #endregion
                }
                dataPagerMain.ChangePageNumber(dataPagerMain._currentPageNumber);
                textBox1.Text = "";
                MessageBox.Show("添加表述成功！");
            }
            catch (Exception error)
            {
                MessageBox.Show("添加表述失败！");
            }
        }


        private void button10_Click(object sender, EventArgs e)
        {
            OpenNodeTree();
        }

        private void OpenNodeTree()
        {
            NodeTree nt1 = NodeTree.Instance;
            nt1.Close();
            NodeTree nt = NodeTree.Instance;
            nt.TypeName = TypeName;
            nt.FirId = FirId;
            nt.LocateNode = expresitu.GetES_SituationIdsById(clicknode.Tag.ToString());
            if (nt.LocateNode.Contains(","))
            {
                nt.LocateNode = nt.LocateNode.Substring(0, nt.LocateNode.IndexOf(","));
            }

            ShowForm(nt);
        }

        private void button11_Click(object sender, EventArgs e)
        {
            ToAddWordBanks();
        }
        private TreeNode editnode = null;//点击获得当前节点
        private void tVCaseCause_MouseDown(object sender, MouseEventArgs e)
        {
            Point ClickPoint = new Point(e.X, e.Y);
            editnode = tVCaseCause.GetNodeAt(ClickPoint);
            if (editnode != null)//判断你点的是不是一个节点
            {
                editnode.ContextMenuStrip = contextMenuStrip1;
            }
        }
        private void 添加要素ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ToAddWordBanks();
        }
        private void AddNodeMenuItem_Click(object sender, EventArgs e)
        {
            group_add.Visible = true;

        }


        private void btn_quit_Click(object sender, EventArgs e)
        {
            group_add.Visible = false;
            TxtCC_ID.Text = "";
            IsMatch2.Checked = true;
            IsAffirmIdeaResult2.Checked = true;
            MatchSource.Text = "0";
            AffirmIdeaSource.Text = "0";

        }

        /// <summary>
        /// 添加节点（只能在组合下添加）
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_add_Click(object sender, EventArgs e)
        {
            SYS_Express_MatchSituation NewModel = new SYS_Express_MatchSituation();
            string CC_ID = TxtCC_ID.Text;
            NewModel.IsMatch = IsMatch2.Checked ? 1 : 0;
            NewModel.MatchSource = MatchSource.Text;
            NewModel.AffirmIdeaResult = IsAffirmIdeaResult2.Checked ? "1" : "2";
            NewModel.AffirmIdeaSource = AffirmIdeaSource.Text;

            string MS_ID = dataprocess_editnode.AddNode(CC_ID, editnode.Tag.ToString(), NewModel);
            //添加完以后界面显示
            if (MS_ID != "")
            {
                MessageBox.Show("添加成功！");
                NewModel = express_matchsituationbll.GetMatchSituation(MS_ID);
                clicknode.Expand();
                TreeNode addnode = new TreeNode();
                addnode.Tag = NewModel.MS_ID;
                addnode.Text = NewModel.SituationName;
                addnode.Name = NewModel.SituationType.ToString();
                clicknode.Nodes.Add(addnode);
            }
            else
            {
                MessageBox.Show("添加失败，节点只能在组合部分添加！");
            }
            group_add.Visible = false;
        }


        #region 情形情节树(条件)

        /// <summary>
        /// 树（第一级）
        /// </summary>
        public void CaseCauseTree_Process()
        {
            DataTable dt = trbll.NodeTree_Tree("");
            DataRow[] arrayDR = dt.Select("name='" + "刑事案由" + "'");

            foreach (DataRow CaseTreeNodeRode in arrayDR)
            {
                TreeNode node = new TreeNode();

                node.Text = LdFormat.ObjectToString(CaseTreeNodeRode[1]) + "(" + LdFormat.ObjectToString(CaseTreeNodeRode[0]) + ")";
                node.Tag = CaseTreeNodeRode[0];
                node.Name = LdFormat.ObjectToString(CaseTreeNodeRode[2]);
                FirId = CaseTreeNodeRode[0].ToString();
                if (trbll.NodeTree_Tree(node.Tag.ToString()).Rows.Count > 0)
                {
                    node.Nodes.Add(new TreeNode());
                }
                NowProcessNode.TreeView.Nodes.Add(node);
            }
        }
        /// <summary>
        /// 下级树
        /// </summary>
        /// <param name="parentNode"></param>
        private void CaseCauseTreeChild_Process(TreeNode parentNode)
        {
            string pid = parentNode.Tag.ToString();
            DataTable CaseTreeNodeRode = trbll.NodeTree_Tree(pid);
            if (CaseTreeNodeRode.Rows.Count == 0)
                return;
            for (int i = 0; i < CaseTreeNodeRode.Rows.Count; i++)
            {
                TreeNode node = new TreeNode();
                node.Text = CaseTreeNodeRode.Rows[i]["name"].ToString() + "(" + CaseTreeNodeRode.Rows[i]["id"].ToString() + ")";


                node.Tag = CaseTreeNodeRode.Rows[i]["id"];
                node.Name = LdFormat.ObjectToString(CaseTreeNodeRode.Rows[i]["CC_NodeType"]);
                if (trbll.NodeTree_Tree(node.Tag.ToString()).Rows.Count > 0)
                {
                    node.Nodes.Add(new TreeNode());
                }
                parentNode.Nodes.Add(node);
            }
        }

        private void NowProcessNode_AfterExpand(object sender, TreeViewEventArgs e)
        {
            e.Node.Nodes.Clear();
            CaseCauseTreeChild_Process(e.Node);
        }

        #endregion

        private void GV_Reg_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                OpenNodeTree();
            }
        }


        private void AgainOrganTree_Click(object sender, EventArgs e)
        {
            if (workThread == null)//创建线程
            {
                #region 查询条件

                DataSourceCondition condi = new DataSourceCondition(); //条件
                #endregion

                workObj = WorkThreadFactory.CreateWorkThreadObj("WorkThread_Order");
                ThreadExecute(condi,null);

            }

        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }








    }
}